<p>从顶部到底部对<code> if </code> / <code> else if </code>语句的链进行评估。最多只执行一个分支,即判断条件不应重复 </p>

<h2>不规范代码示例</h2>

<pre>
if (param == 1)
  openWindow();
else if (param == 2)
  closeWindow();
else if (param == 1)  // 不合规
  moveWindowToTheBackground();
}

</pre>
<h2>正确代码示例</h2>

<pre>
if (param == 1)
  openWindow();
else if (param == 2)
  closeWindow();
else if (param == 3)
  moveWindowToTheBackground();
}

</pre>
<h2>更多</h2>

<ul>
<li> <a href="https://www.securecoding.cert.org/confluence/x/NYA5">CERT, MSC12-C</a> - Detect and remove code that has no effect</li>
<li> <a href="https://www.securecoding.cert.org/confluence/x/SIIyAQ">CERT, MSC12-CPP</a> - Detect and remove code that has no effect</li>
</ul>

